<template>
  <div style="width: 100%; height: 100%" ref="chart"></div>
</template>

<script>
import CommonMixin from "../mixins/commonMixin";
import { getAction } from "../../../utils/request";
export default {
  name: "v-map-chart",
  mixins: [CommonMixin],
  methods: {
    init() {
      if (!window._charts) {
        window._charts = {};
      }
      this.$nextTick(() => {
        window._charts[this.id] = window.echarts.init(this.$refs.chart);
        getAction("/map/" + this.config.climecode + ".json").then((res) => {
          window.echarts.registerMap(this.config.climecode, res);
          window._charts[this.id].setOption(this.config.option, true);
        });
      });
    },
    update() {
      getAction("/map/" + this.config.climecode + ".json").then((res) => {
        window.echarts.registerMap(this.config.climecode, res);
        window._charts[this.id].setOption(this.config.option, true);
      });
    },
    resize() {
      window._charts[this.id].resize();
    },
  },
};
</script>

<style scoped></style>
